package methodEmbedding.Revenge_of_the_Pancakes.S.LYD261;

/*
 * Copyright 2014 Norbert Potocki <norbert.potocki@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.Scanner;

/**
 * @author <a href="mailto:norbert.potocki@gmail.com">Norbert Potocki</a>
 */
public class ProblemB {

  public static void main(String[] args) throws Exception {

    Scanner in = new Scanner(System.in);

    int t = in.nextInt();

    for (int t_ = 0; t_ < t; t_++) {

      String code = in.next();

      String prefix = "Case #" + (t_ + 1) + ": ";

      char last = code.charAt(0);
      int moves = 0;

      for (char c : code.toCharArray()) {
        if(c != last) {
          moves++;
          last = c;
        }
      }

      moves += last == '-' ? 1 : 0;

      System.out.println(prefix + moves);
    }
  }
}
